import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uni(),
  ],
  server: {
    port: 5173, // 自定义开发服务器端口
    open: true,
    proxy: {
      // 将 /api 请求代理到后端服务，避免跨域
      '/api': {
        target: 'http://localhost:8089', // 你的后端地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `
          @import "uview-plus/theme.scss";
          @import "uview-plus/index.scss";
        `
      }
    }
  }
})
